<?PHP
$PurviewLevel=0;
ob_start();  
require("../../inc/common.inc.php");
ob_end_clean();
require_once(dirname(__FILE__)."/../"."Admin_ChkPurview.php");
/**
*处理添加新消息
**/
if($action=="saveadd"){
if(intval($tuserid)==0){
	$fun->popmassage("参数错误","","popback");
	exit();
}
$appuserstr=$tuserid.",";
if ($ttitle=="" || empty($ttitle)){
	$fun->popmassage("信息标题不能为空","","popback");
	exit();
}
$ttype = intval($ttype);
$tsucaiid = intval($tsucaiid);
$tmsgid = intval($tmsgid);

if($ttype==1){
	if ($tcontent=="" || empty($tcontent)){
	$fun->popmassage("请设置消息的内容","","popback");
	exit();
	}
}elseif ($ttype==5){
	if($tmsgid==0){
	$fun->popmassage("请设置消息的内容","","popback");
	exit();
	}
}else{
	if($tsucaiid==0){
	$fun->popmassage("请设置消息的内容","","popback");
	exit();
	}
}
$addtime = mktime();
$tgroupid=intval($tgroupid);
$tsex=intval($tsex);
$truepath=preg_replace("/(.+)\/([^\/]+)\/([^\/]+)/is","\\1",'http://'.$HTTP_HOST.$PHP_SELF);
$tcontent=str_replace($truepath,"",$tcontent);
$tcontent=str_replace("﹪","%",$tcontent);
$tcontent=mysql_escape_string($tcontent);
		
$db->excu("INSERT INTO `mx_tuisong_vpp` ( `ttitle`, `ttype`,`tcontent`,`tsucaiid`,`tmsgid`,`tuserids`,`addtime`,`addid`) VALUES ('$ttitle','$ttype','$tcontent','$tsucaiid','$tmsgid','$vppuserstr','$addtime','".$_SESSION['mxadmin']['userid']."')");
$tid = mysql_insert_id();

setcookie("vppusers","",time()-3600);
setcookie("vppusersnum","0",time()-3600);

if($vppuserstr!=""){
	$vppuserstr = substr($vppuserstr,0,strlen($vppuserstr)-1);
	$vppuserarr = split(",",$vppuserstr);
	foreach($vppuserarr as $key => $value){
		$db->excu("INSERT INTO `mx_tuisong_vpp_log` ( `tid`, `userid`,`viewtype`,`addtime`) VALUES ('$tid','".$value."','0','$addtime')");
	}
}

jump2("操作成功","tuisong_vpp_list.php",2);
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link href="../images/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php require("../mx_head.php") ;?>

	<!--right-->
	<div class="right">
	  
		<div class="xm2">
			<h1 class="fl">VPP信息</h1>
			<!--<span class="fr"><a href="#"><img src="../images/right_4.png" alt="设置" /></a></span>-->
			<div class="clear"></div>
		</div>
		<div class="xm2_b">
			<div class="height15"></div>
				<script type="text/javascript" src="../js/jquerys-1.5.1.js"></script>
                <script type="text/javascript" src="../js/pcasunzip.js"></script>
                <script type="text/javascript" src="../js/tuisong.js"></script>
				<script language="javascript">
				$(document).ready(function(){ //这个就是传说的ready   
				$(".stripe tr").mouseover(function(){   
				//如果鼠标移到class为stripe的表格的tr上时，执行函数   
				$(this).addClass("over");}).mouseout(function(){   
				//给这行添加class值为over，并且当鼠标一出该行时执行函数   
				$(this).removeClass("over");}) //移除该行的class   
				$(".stripe tr:even").addClass("alt");   
				//给class为stripe的表格的偶数行添加class值为alt
				//www.divcss5.com 整理特效
				});  
				function showinfo(returnid,changeid,changevalue){
					document.getElementById(changeid).value=changevalue;
					$.ajax({ url: "getinfo.php?id="+changevalue+"&cid="+changeid,success: function(msg){
					  document.getElementById(returnid).innerHTML=msg;
					}});

					
				}
				function checkform(){
					var ttitle,ttype,tsucaiid,tmsgid;
					ttitle = document.form2.ttitle.value;
					ttype = document.form2.ttype.value;
					tsucaiid = document.form2.tsucaiid.value;
					tmsgid = document.form2.tmsgid.value;
					tcontent = document.form2.tcontent.value;
					
					if(ttitle==""){
						alert("信息标题不能为空");
						document.form2.ttitle.focus();
						return false;
					}
					
					if(ttype==1){
						if(tcontent==0){
							alert("请设置消息的内容");
							return false;
						}
					}else if(ttype==5){
						if(tmsgid==0){
							alert("请设置消息的内容");
							return false;
						}
					}else{
						if(tsucaiid==0){
							alert("请设置消息的内容");
							return false;
						}
					}
					return true;
			    }
				
				</script>
				<form id="form2" name="form2" method="post" action="?action=saveadd" onsubmit="return checkform()">
                <input type="hidden" name="ttype" id="ttype" value="1">
                <input type="hidden" name="tsucaiid" id="tsucaiid" value="0">
                <input type="hidden" name="tmsgid" id="tmsgid" value="0">
                <input type="hidden" name="tuserid" id="tuserid" value="<?php echo $id;?>">
				  <table width="100%" border="0" align="left" cellpadding="9" cellspacing="0">
                    
                    
                    
                    <tr>
                      <td width="143" align="right" class="font14">信息标题：</td>
                      <td colspan="2"><input type="text" name="ttitle" size="70" value="" /></td>
                    </tr>
                    <script>
					function switchmod(modtag,modtagclass1,modtagclass2,modk,modknum)
					{
						document.getElementById("ttype").value=modk;
						document.getElementById("tsucaiid").value=0;
						document.getElementById("tmsgid").value=0;
						for(i=1; i <=modknum; i++)
						{
							content=modtag+"_list"+i;
							if (i==modk)
							{
							document.getElementById(modtag+i).className=modtagclass1;
							document.getElementById(content).style.display="block";
							}
							else
							{
							document.getElementById(modtag+i).className=modtagclass2;
							document.getElementById(content).style.display="none";
							}
							document.getElementById("list"+i).innerHTML="";
						}
					}
					
					</script>
                    <tr>
                      <td align="right" class="font14">信息类型：</td>
                      <td colspan="2">
                      <input type="button" class="button" value="文字" id="tab_1" onclick="switchmod('tab_','button','button2',1,5)">&nbsp;
                      <input type="button" class="button2" value="语音" id="tab_2" onclick="switchmod('tab_','button','button2',2,5)">&nbsp;
                      <input type="button" class="button2" value="图片" id="tab_3" onclick="switchmod('tab_','button','button2',3,5)">&nbsp;
                      <input type="button" class="button2" value="视频" id="tab_4" onclick="switchmod('tab_','button','button2',4,5)">&nbsp;
                      <input type="button" class="button2" value="图文消息" id="tab_5" onclick="switchmod('tab_','button','button2',5,5)">
                      </td>
                    </tr>
                    <tr>
                      <td align="right" class="font14">&nbsp;</td>
                      <td colspan="2">
                      <div id="tab__list1">
                      <script charset="utf-8" src="/webedito/kindeditor-min.js"></script>
					  <script charset="utf-8" src="/webedito/lang/zh_CN.js"></script>
                      <script>
                      var editor;
                      KindEditor.ready(function(K) {
                          editor = K.create('textarea[id="content"]', {
                            allowFileManager : true,
                            filterMode : false,
                            afterBlur : function() {this.sync();}
                          });
                      });
                      </script>
                      <style>
					  .tab_box{height:200px; width:80%;line-height:20px;padding:20px; border:#ccc 1px solid;-moz-border-radius:3px;/*仅Firefox支持，实现圆角效果*/-webkit-border-radius:3px;/*仅Safari,Chrome支持，实现圆角效果*/-khtml-border-radius:3px;/*仅Safari,Chrome支持，实现圆角效果*/border-radius:3px;/*仅Opera，Safari,Chrome支持，实现圆角效果*/ overflow-y:auto;}
					  .abutton{ height:30px; line-height:20px; padding-left:20px;}
					  </style>
                      <textarea name="tcontent" id="content" style="width:80%;height:300px;visibility:hidden;display:none;"></textarea>
                      <div id="list1">
                      </div>
                      </div>
                      <div id="tab__list2" style="display:none;">
                      <p class="abutton"><a href="javascript:showdiv('list2','tsucaiid','tuisong_music_list','语音素材')">点击选取语音素材</a></p>
                      <div id="list2" class="tab_box">
                      </div>
                      </div>
                      <div id="tab__list3" style="display:none;">
                      <p class="abutton"><a href="javascript:showdiv('list3','tsucaiid','tuisong_pic_list','图片素材')">点击选取图片素材</a></p>
                      <div id="list3" class="tab_box">
                      </div>
                      </div>
                      <div id="tab__list4" style="display:none;">
                      <p class="abutton"><a href="javascript:showdiv('list4','tsucaiid','tuisong_video_list','视频素材')">点击选取视频素材</a></p>
                      <div id="list4" class="tab_box">
                      </div>
                      </div>
                      <div id="tab__list5" style="display:none;">
                      <p class="abutton"><a href="javascript:showdiv('list5','tmsgid','tuisong_msg_list','图文消息')">点击选取图文消息</a></p>
                      <div id="list5" class="tab_box">
                      </div>
                      </div>
                      </td>
                    </tr>
                    
                    
                    <tr>
                      <td>&nbsp;</td>
                      <td class="font14" colspan="2"><input type="submit" class="button" name="button" id="button" value="完成" />&nbsp;&nbsp;
                      <input type="reset" class="button2" name="button2" id="button2" value="取消" /></td>
                    </tr>
                    <tr>
                      <td colspan="3" height="20">&nbsp;</td>
                    </tr>
                  </table>
          </form>
				<div class="height15"></div>
	  </div>
		<div class="clear"></div>
		<div class="height15"></div>
       
	  </div>
		<div class="clear"></div>
  <?php require("../mx_foot.php") ;?>
  </div>
	<!--right-end-->
</body>
</html>
